bin=httpserver
cc=g++
LD_FLAGS=-std=c++11 -lpthread #-DDEBUG=1
curr=$(shell pwd)    #   $(shell pwd)的意思是使用shell执行pwd命令   然后定义给curr   makefile
src=main.cc

.PHONY:ALL
ALL:$(bin) CGI   #all:httpserver CGI

$(bin):$(src)    #httpserver:main.cc
	$(cc) -o $@ $^ $(LD_FLAGS)    #g++ -o $@ $^ -std=c++11 -lpthread

CGI:
	cd $(curr)/cgi;\
		make;\
		cd -;

.PHONY:clean
clean:
	rm -f $(bin)    #rm -f httpserver
	rm -rf output   #rm -rf output
	cd $(curr)/cgi;\   #这三行相当于连续手敲 cd $(curr)/cgi; make clean; cd -
		make clean;\
		cd -

.PHONY:output
output:
	mkdir -p output
	cp $(bin) output
	cp -rf wwwroot output
	cp ./cgi/test_cgi output/wwwroot
	cp ./cgi/shell_cgi.sh output/wwwroot
	cp ./cgi/python_cgi.py output/wwwroot
	cp ./cgi/mysql_cgi output/wwwroot